home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / win / dviwin29.zip / GENPK2.CMD < prev    next >
OS/2 REXX Batch file  |  1994-12-01  |  8KB  |  205 lines

  1. /*
  2.  * This is a sample REXX file to run metafont, convert the GF file to
  3.  * the PK format and store the PK font in the appropriate directory. It
  4.  * is meant to be called by dviwin and that's the reason for the absence
  5.  * of any parameter checking. It also assumes that metafont and gftopk
  6.  * are operating properly. This is a sample file and attempts to cover
  7.  * as many devices as possible; you will probably get better and faster
  8.  * results if you write a smaller and more specialized file.
  9.  *
  10.  * The plain base is a prerequisite: make sure that you generate it by
  11.  * running inimf on plain.mf, then input the file modes.mf (version 2.1
  12.  * or later; you can get it from the directory /tex-archive/fonts/modes
  13.  * at the CTAN hosts: ftp.shsu.edu, ftp.dante.de and ftp.tex.ac.uk; some
  14.  * modes will not work properly with earlier versions of the modes.mf
  15.  * file) and finally dump the format file. If you don't know what I am
  16.  * talking about, please read the documentation that comes with the
  17.  * metafont program, as well as the Metafont book.
  18.  *
  19.  * You WILL need to modify the routine to place the PK files in the
  20.  * proper directory; the current method uses the environment variable
  21.  * DVIFONTS which is assumed to contain the base directory for the PK
  22.  * fonts. Any square-pixel fonts are assumed to be stored in the
  23.  * directories  $(DVIFONTS)\X  where X is the resolution of the font.
  24.  * Non-square-pixel fonts are assumed to stored in the directories
  25.  * $(DVIFONTS)\XxY where X is the horizontal resolution and Y is the
  26.  * vertical resolution.
  27.  *
  28.  * It is trivial to modify the name of metafont and the base directory;
  29.  * just select the proper values for the first two statements after
  30.  * these comments. If however you use another directory structure, you
  31.  * will also need to modify the definition of the variable pkdir_.
  32.  *
  33.  * You may also need to do more modifications if you have other devices;
  34.  * this file generates fonts for the screen, 300dpi laser and inkjet
  35.  * printers, printers, 600dpi laserjets, as well as 9-pin and 24-pin dot
  36.  * matrix printers. If you want to use another device, you will have to
  37.  * understand the code below and modify it accordingly (maybe you will
  38.  * want to rewrite the code in a compiled language to improve the speed,
  39.  * and the error handling). If you want to use a 9-pin dot matrix printer
  40.  * at 120x144dpi or 240x144dpi, or an HP Deskjet 520 at 600x300dpi, append
  41.  * the following lines to the file modes.mf and regenerate the plain base.
  42.  *
  43.  * mode_def epsmed =        % Epson-FX at 240x144dpi
  44.  *     mode_param (pixels_per_inch, 240);
  45.  *     mode_param (aspect_ratio, 144 / pixels_per_inch);
  46.  *     EpsonMXFX_;
  47.  * enddef;
  48.  *
  49.  * mode_def epsmedl =        % Lanscape version of epsmed
  50.  *    epsmed_;
  51.  *    landscape;
  52.  * enddef;
  53.  *
  54.  * mode_def epswlo =        % Epson-FX at 120x144dpi
  55.  *     mode_param (pixels_per_inch, 120);
  56.  *     mode_param (aspect_ratio, 144 / pixels_per_inch);
  57.  *     EpsonMXFX_;
  58.  * enddef;
  59.  *
  60.  * mode_def epswlol =        % Lanscape version of epswlo
  61.  *    epswlo_;
  62.  *    landscape;
  63.  * enddef;
  64.  *
  65.  * mode_def DJFiveTwenty =    % HP Deskjet at 600x300dpi
  66.  *    mode_param (pixels_per_inch,600);
  67.  *    mode_param (aspect_ratio, 300 / pixels_per_inch);
  68.  *    deskjet_;
  69.  * enddef;
  70.  *
  71.  * mode_def DJFiveTwentyl =    % Landscape version of DJFiveTwenty
  72.  *    DJFiveTwenty_;
  73.  *    landscape;
  74.  * enddef;
  75.  *
  76.  * If Metafont does not recognize any other modes, it will generate
  77.  * its standard proofing fonts which are HUGE and inappropriate for
  78.  * your device. In that case, get the file modes.mf from CTAN and
  79.  * generate the plain base again using the command:
  80.  *         inimf plain;input modes;dump
  81.  * Then you need to copy plain.bas to the appropriate directory. You
  82.  * may need to replace "inimf" by "mf -i" for some versions of Metafont
  83.  *
  84.  * Here are the parameters passed by dviwin:
  85.  */
  86.     fname_    = WORD(ARG(1),1)
  87.     magst_    = WORD(ARG(1),2)
  88.     xres_    = WORD(ARG(1),3)
  89.     yres_    = WORD(ARG(1),4)
  90.     xbase_    = WORD(ARG(1),5)
  91.     ybase_    = WORD(ARG(1),6)
  92.     gfext_    = WORD(ARG(1),9)
  93. /*
  94.  * In most cases, you will only need to modify the next four lines:
  95.  */
  96.     mfcmd_    = 'mf'
  97.     pkbase_ = value('DVIFONTS',,'OS2ENVIRONMENT')
  98.     IF xbase_ = ybase_ THEN    pkdir_ = pkbase_'\'xres_
  99.     ELSE            pkdir_ = pkbase_'\'xres_'x'yres_
  100. /*
  101.  * Switch to the $TEMP or $TMP directory
  102.  */
  103.     temp_ = value('TEMP',,'OS2ENVIRONMENT')
  104.     if temp_ = '' THEN temp_ = value('TMP',,'OS2ENVIRONMENT')
  105.     CALL directory(temp_)
  106. /*
  107.  * If you want to switch to the directory of the current dvi file, uncomment
  108.  * the next statement. This is useful if you prefer to keep some mf sources
  109.  * in the dvi file directory instead of the $MFINPUTS directory.
  110.  *
  111.  * CALL directory(WORD(ARG(1),7)':'WORD(ARG(1),8))
  112.  */
  113. IF xbase_ = ybase_ THEN        /* Square pixels */
  114.     DO
  115.     IF    xbase_ = 180    THEN pkdev_ = 'lqlores'
  116.     ELSE IF    xbase_ = 360    THEN pkdev_ = 'lqhires'
  117.     ELSE IF    xbase_ = 300    THEN pkdev_ = 'hplaser'
  118.     ELSE IF    xbase_ = 400    THEN pkdev_ = 'nexthi'
  119.     ELSE IF    xbase_ = 600    THEN pkdev_ = 'ljiv'
  120.     ELSE
  121.         DO
  122.         pkdev_ = 'hplaser'
  123.         IF    xres_ =  58    THEN magst_ = -9
  124.         ELSE IF    xres_ =  64    THEN magst_ = -8.5
  125.         ELSE IF    xres_ =  70    THEN magst_ = -8
  126.         ELSE IF    xres_ =  76    THEN magst_ = -7.5
  127.         ELSE IF    xres_ =  84    THEN magst_ = -7
  128.         ELSE IF    xres_ =  92    THEN magst_ = -6.5
  129.         ELSE IF    xres_ = 100    THEN magst_ = -6
  130.         ELSE IF    xres_ = 110    THEN magst_ = -5.5
  131.         ELSE IF    xres_ = 121    THEN magst_ = -5
  132.         ELSE IF    xres_ = 132    THEN magst_ = -4.5
  133.         ELSE IF    xres_ = 145    THEN magst_ = -4
  134.         ELSE IF    xres_ = 158    THEN magst_ = -3.5
  135.         ELSE IF    xres_ = 174    THEN magst_ = -3
  136.         ELSE IF    xres_ = 190    THEN magst_ = -2.5
  137.         ELSE IF    xres_ = 208    THEN magst_ = -2
  138.         ELSE IF    xres_ = 228    THEN magst_ = -1.5
  139.         ELSE IF    xres_ = 250    THEN magst_ = -1
  140.         ELSE IF    xres_ = 274    THEN magst_ = -0.5
  141.         ELSE IF    xres_ = 300    THEN magst_ =  0
  142.         ELSE IF    xres_ = 329    THEN magst_ =  0.5
  143.         ELSE IF    xres_ = 360    THEN magst_ =  1
  144.         ELSE IF    xres_ = 394    THEN magst_ =  1.5
  145.         ELSE IF    xres_ = 432    THEN magst_ =  2
  146.         ELSE IF    xres_ = 473    THEN magst_ =  2.5
  147.         ELSE IF    xres_ = 518    THEN magst_ =  3
  148.         ELSE IF    xres_ = 568    THEN magst_ =  3.5
  149.         ELSE IF    xres_ = 622    THEN magst_ =  4
  150.         ELSE IF    xres_ = 681    THEN magst_ =  4.5
  151.         ELSE IF    xres_ = 746    THEN magst_ =  5
  152.         ELSE IF    xres_ = 818    THEN magst_ =  5.5
  153.         ELSE IF    xres_ = 896    THEN magst_ =  6
  154.         ELSE IF    xres_ = 981    THEN magst_ =  6.5
  155.         ELSE IF    xres_ = 1075    THEN magst_ =  7
  156.         ELSE IF    xres_ = 1178    THEN magst_ =  7.5
  157.         ELSE IF    xres_ = 1290    THEN magst_ =  8
  158.         ELSE SIGNAL UNKNOWN
  159.         END
  160.     END
  161. ELSE                /* Non-square pixels */
  162.     DO
  163.     IF    xbase_ = 120 & ybase_ =  72    THEN pkdev_ = 'epsdrft'
  164.     ELSE IF    xbase_ = 120 & ybase_ = 144    THEN pkdev_ = 'epswlo'
  165.     ELSE IF    xbase_ = 240 & ybase_ = 144    THEN pkdev_ = 'epsmed'
  166.     ELSE IF    xbase_ = 240 & ybase_ = 216    THEN pkdev_ = 'epson'
  167.     ELSE IF    xbase_ = 360 & ybase_ = 180    THEN pkdev_ = 'lqmed'
  168.     ELSE IF xbase_ = 600 & ybase_ = 300    THEN pkdev_ = 'DJFiveTwenty'
  169.     ELSE IF xbase_ =  72 & ybase_ = 120    THEN pkdev_ = 'epsdrftl'
  170.     ELSE IF xbase_ = 144 & ybase_ = 120    THEN pkdev_ = 'epswlol'
  171.     ELSE IF xbase_ = 144 & ybase_ = 240    THEN pkdev_ = 'epsmedl'
  172.     ELSE IF xbase_ = 216 & ybase_ = 240    THEN pkdev_ = 'epsonl'
  173.     ELSE IF xbase_ = 180 & ybase_ = 360    THEN pkdev_ = 'lqmedl'
  174.     ELSE IF xbase_ = 300 & ybase_ = 600    THEN pkdev_ = 'DJFiveTwentyl'
  175.     ELSE SIGNAL UNKNOWN
  176.     END
  177. CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  178. CALL SysLoadFuncs
  179. RESULT = STREAM(pkdir_'\'fname_'.pk','c','query exists')
  180. IF RESULT <> '' THEN EXIT
  181. mfcmd_' \scrollmode;mode:='pkdev_';mag:=magstep('magst_');input 'fname_
  182. IF RC > 0 THEN SIGNAL ERROR_EXIT
  183. CALL SysMkDir(pkbase_)
  184. CALL SysMkDir(pkdir_)
  185. RESULT = stream(fname_'.'gfext_,'c','query exists')
  186. IF RESULT = '' THEN gfext_ = xres_
  187. gftopk fname_'.'gfext_ pkdir_'\'fname_'.pk'
  188. CALL SysFileDelete(fname_'.'gfext_)
  189. CALL SysFileDelete(fname_'.log')
  190. /*
  191.  * If you want to copy the TFM file to the appropriate directory, here
  192.  * is the place to do it.
  193.  */
  194. CALL SysFileDelete(fname_'.tfm')
  195. EXIT
  196.  
  197. /*
  198.  * This is where we come if we don't know about the requested resolution
  199.  */
  200. UNKNOWN:    SAY "I don't know the Metafont mode for this device. Please"
  201.         SAY "add this information to the file genpk.cmd"
  202. ERROR_EXIT:    SAY "Press Enter to continue..."
  203.         PULL junk_
  204.         EXIT
  205.